import {FORWARD} from '@/services/api'
import {request,requestfile, METHOD} from '@/utils/request'

export async function ajaxrequest(account_id,url, params) {
  var dataval = Object.assign({
      "advertiser_id":account_id
  },params)
    return request(FORWARD, METHOD.POST, {
        "account_id": account_id,
        "uri":url,
        "param":dataval
    })
}

export async function ajax(url) {
  return request(url, METHOD.POST)
}

//带参数得post请求
export async function ajaxparems(url,params) {
  return request(url, METHOD.POST,params)
}

//get请求
export async function ajaxget(url) {
  return request(url, METHOD.GET)
}

export async function ajaxnoparams(account_id,url, params) {
    return request(FORWARD, METHOD.POST, {
        "account_id": account_id,
        "uri":url,
        "method":"post",
        "param":params
    })
}

//上传请求
export async function ajaxfile(url, params) {
    let headers = {
      headers: { "Content-Type": "multipart/form-data" }
    };
    return requestfile(url, METHOD.POST,params,headers)
}
// export async function ajaxnoparams(url,params) {
//   return request(url, METHOD.POST,params)
// }

export default {
  ajaxrequest,
  ajax,
  ajaxnoparams,
  ajaxget,
  ajaxparems,
  ajaxfile
}